﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    assembly="SAKS.Models"
    namespace="SAKS.Models">
  <class name="User" table="SAKS_User">
    <id name="Id" column="UserId">
      <generator class ="guid.comb" />
    </id>
    <natural-id >
      <property name="UserName" not-null="true"/>
    </natural-id>
    <version name="Version" />
    <property name="LoweredUserName" not-null="true"/>
    <property name="MobileAlias" />
    <property name="IsAnonymous" not-null="true"/>
    <property name="LastActivityDate" not-null="true"/>
    
    <one-to-one name="Membership" class="SAKS.Models.Membership" cascade="all" lazy="proxy"/>
      
    <bag name="Projects" table="User_In_Project" cascade="save-update" inverse="false">
      <key column="UserId" not-null="true"/>
      <many-to-many class="SAKS.Models.Project,SAKS.Models" column="ProjectId" />
    </bag>
    <bag name="Roles" table="User_In_Role" cascade="save-update" inverse="false">
      <key column="UserId" not-null="true"/>
      <many-to-many class="SAKS.Models.Role,SAKS.Models" column="RoleId" />
    </bag>

  </class>

</hibernate-mapping>